Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Direct pass #2155

Merged
merged 3 commits into from
Jan 23, 2024
Merged

Direct pass #2155

merged 3 commits into from
Jan 23, 2024

Conversation

sanatd33
Copy link
Contributor

Description

Modifies the code in offense.cpp to only pass to another offense robot if that target robot is open.

Associated / Resolved Issue

Resolves https://app.clickup.com/t/86ayr29tq

Steps to Test

make run-sim
Robots 1, 2, and 4 are set to Offense by default and forced into the 'Awaiting Passing' state.

Expected result: If either robots 1, 2, or 4 have possession of the ball, they will pass it to another Offense robot, provided that it is open.

Key Files to Review

  • offense.cpp

Review Checklist

  • Docstrings: All methods and classes should have the file appropriate docstrings which follow the guidelines in the "Contributing" page of our docs.
  • Remove extra print statements: Any print statements used for debugging should be removed
  • Tag reviewers: Tag some people for review and ping them on Slack

(Optional) Sub-issues (for drafts)

Note: if you find yourself breaking this PR into many smaller features, it may make sense to break up the PR into logical units based on these features.

  • Step 1
  • Step 2

Copy link
Contributor

@sid-parikh sid-parikh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left a number of comments. I also want to discuss the overall effect of this PR, but that may have to wait until some other tasks are finished.

@@ -171,8 +171,8 @@ class PlaySelector(situation.IPlaySelector):
"""

def __init__(self):
self.curr_situation = situations.Defense
self.curr_play = defense.Defense()
self.curr_situation = situations.Offense
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please uncommit changes to rj_gameplay

if (buffered_responses_[i].associated_request == agent_response.associated_request) {
// add the robot id in the corresponding (increasing) location in the received_robot_ids
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a reason this comment was removed? is it inaccurate somehow?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like all the changes to this file were formatting. unless you needed to change this file for your work, uncommit these changes too.

@@ -203,11 +210,44 @@ communication::PosAgentResponseWrapper Offense::receive_communication_request(
std::get_if<communication::ResetScorerRequest>(&request.request)) {
communication::Acknowledge response = receive_reset_scorer_request();
comm_response.response = response;
} else if (const communication::PassRequest* pass_request =
std::get_if<communication::PassRequest>(&request.request)) {
rj_geometry::Point robot_position = world_state()->get_robot(true, robot_id_).pose.position();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you please add some comments clearly explaining the logic implemented here?

}

return comm_response;
}

communication::PassResponse Offense::receive_pass_request(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pass pass_request by const reference here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hold on, was this copied directly from Position? why don't we just call Position::receive_past_request() in that case?

@@ -172,6 +175,10 @@ std::optional<RobotIntent> Offense::state_to_task(RobotIntent intent) {
planning::MotionCommand{"path_target", current_location_instant, face_ball};
intent.motion_command = face_ball_cmd;
return intent;
} else if (current_state_ == AWAITING_SEND_PASS) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we really be standing perfectly still and doing nothing while waiting to pass? it's okay for now but let's have a discussion about this and how this entire state machine operates.

@@ -166,6 +166,19 @@ void Position::send_direct_pass_request(std::vector<u_int8_t> target_robots) {
communication_request_ = communication_request;
}

void Position::broadcast_direct_pass_request() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a useful addition

@@ -296,9 +296,9 @@ void CoachNode::assign_positions_normal(std::array<uint32_t, kNumShells>& positi
positions[robot_id] = Positions::Offense;
break;
case 2:
positions[robot_id] = Positions::Defense;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uncommit these changes if they were just for testing.

@@ -256,7 +258,7 @@ class Position {
const int robot_id_;

// the robot our robot is going to be passing to
int target_robot_id;
int target_robot_id = 10;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the purpose of this default?

automated style fixes

Co-authored-by: sanatd33 <[email protected]>
@sid-parikh sid-parikh merged commit 9d6acba into ros2 Jan 23, 2024
2 checks passed
@sid-parikh sid-parikh deleted the direct-pass branch January 23, 2024 17:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants